<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<include file="Public/head" />
		<link href="__PUBLIC__/Wchat/css/logincss.css?v=<?=time()?>" rel="stylesheet">
		<title>登录</title>
	 <style>
	     .logo{
	         background: rgb(255, 209, 27);
	
	color: #ffffff;
	text-align: center;
	height:108px;
	    
    font-size: 30px;
    letter-spacing: 5px;
    font-weight: 600;
	     }
	     
.websitename_box
{
	bottom: 0;
}

.websitename_box
{background: rgb(255, 209, 27);
       display:table-cell;      /*按照单元格的样式显示元素*/
vertical-align:bottom;   /*底对齐*/
	position: absolute;
	width: 100%;
	height: 90%;
	font-size: 30px;
	letter-spacing: 5px;
	font-weight: 600;
}

.websitename
{
	width: 100%;
 
	display: flex;
	display: -webkit-flex;
	bottom: 0;
	align-items: center;
	align-content: center;
}

.websitename div
{
	width: 100%;
}

.head_bottom_box
{
	position: absolute;
	width: 100%;
	bottom: 0;
	padding: 15px 0;
	letter-spacing: 5px;
	font-size: 18px;
}
.res_con .yz img{
    position: absolute;
    width: 5rem;
    line-height: 2rem;
    height: 2rem;
    display: block;
    color: #fff;
    right: 10%;
    background: #1776d4;
    font-size: 0.9rem;
    top: 0.5rem;
    text-align: center;
    border-radius: 7px;
    border: 0;
}
	 </style>
	</head>
	<body>
	    
		<div class="logo" >
		    <div class="websitename_box">
			<div class="websitename">
				<div>
					 <config name="siteName" /> 				</div>
			</div>
		</div>
	   
	    </div>
	    <div class="login_res">
	     	<div class="tab">
	        	<ul>
	            	<li>
	                	<em></em>
	                    <em></em>
	                    <span>登录</span>
	                </li>
	                <li class="action">
	                	<em></em>
	                    <em></em>
	                    <span>注册</span>
	                </li>
	            </ul>
	       </div>
	        <div class="con">
	            <div class="login_con">
	            	<form action="{:U('Index/ajaxLogin')}" method="post" id="loginForm">
		            	<ul>
		                	<li>
		                		<input type="number" placeholder="请输入11位数字" class="user" name="username">
		                	</li>
		                    <li class="fu_pwd">
		                    	<input type="password" placeholder="请输入登录密码" class="pwd" name="password">
		                    	<a href="{:U('Index/forgetpwd')}">忘记密码？</a>
		                    </li>
		                </ul>
		                <button class="abut" type="button" id="loginBtn">登录</button>
	            	</form>
	            </div>
	            <div class="res_con">
					<form action="{:U('Index/ajaxReg')}" method="post" id="regForm">
		            	<ul>
		                	<li>
		                		<input type="text" placeholder="请输入11位数字" class="user">
		                	</li>
		                    <li class="yz">
		                    	<input type="text" placeholder="请输入验证码" class="yzm">
		                   <!-- <button type="button">发送验证码</button>-->
		                    	<img src="{:U('Index/verify',array('t','randTime'))}">
		                    </li>
		                    <li class="fu_pwd">
		                    	<input type="password" placeholder="请输入登录密码" class="pwd">
		                    </li>
		                </ul>
		                <p><img src="__PUBLIC__/Wchat/images/queren.png">我以阅读并同意<a href="{:U('Page/protocol')}">《<config name="siteName" />服务协议》</a></p>
		                <button class="abut1" type="button" id="regBtn" disabled="disabled">注册</button>
		                <div class="verify">
		                	<p>
		                		<img src="{:U('Index/verify')}" alt="看不清,换一张" />
		                	</p>
		                	<p>
		                		<input type="number" value="" placeholder="输入验证码" />
		                	</p>
		                	<p>
		                		<a class="btn" id="verifySendcode">确定</a>
		                		<a class="btn btnred" id="verifyClose">取消</a>
		                	</p>
		                </div>
					</form>
	            </div>
	        </div>
	    </div>
	    <div class="zhezhao"></div>
	    <div class="footer">
	    	<!--<img src="__PUBLIC__/Wchat/images/logo_foot.png">-->
	       	<config name="siteCorporate" />
	    </div>
	      <php>$servicesCode= empty(C('servicesCode'))?'':htmlspecialchars_decode(htmlspecialchars_decode(C('servicesCode')));</php>
{$servicesCode|default=''}
      </div>
	 	<script type="text/javascript">
		//本脚本解决点击后跳出safari的问题
		(function(){	
			if ("standalone" in window.navigator && window.navigator.standalone) {
				var d, l = false;
				document.addEventListener("click", function(i) {
					d = i.target;
					while (d.nodeName !== "A" && d.nodeName !== "HTML") d = d.parentNode;
					//if ("href" in d && d.href.indexOf("http") !== -1 && (d.href.indexOf(document.location.host) !== -1 || l)) {
					if ("href" in d && d.href.indexOf("http") !== -1 ) {
						i.preventDefault();
						document.location.href = d.href
					}
				}, false)
			}
		}());
		
		</script>
	    
	    <script>
	    function getImg()
	    {
	        	var imgUrl = "{:U('Index/verify',array('t','randTime'))}";
                	    			imgUrl = imgUrl.replace(/randTime/,Date.parse(new Date()));
                	    			$(".yz img").attr('src',imgUrl);
	    }
	    	var resendTime = 0;
	    	var resendFun;
	    	$(function(){
	    		/*登录*/
	    		$("#loginBtn").on('click',function(){
	    			if(!cvphp.ismobile( $("#loginForm .user").val() )){
	    				cvphp.msg({
	    					content: '手机号码不符合规范'
	    				});
	    				return false;
	    			}
	    			if(! $("#loginForm .pwd").val() ){
	    				cvphp.msg({
	    					content: '请输入登录密码'
	    				});
	    				return false;
	    			}
	    			cvphp.submit($("#loginForm"),function(data){
	    				if(data.status != 1){
	    					cvphp.msg({
	    						content: data.info,
	    					});
	    				}else{
	    					cvphp.msg({
	    						content: '登录成功',
	    					});
	    					setTimeout(function(){window.location.href = data.url;},3000);
	    				}
	    			});
	    			return false;
	    		});
	    		/*注册*/
	    		$(".res_con .yz button").on('click',function(){
	    			if(!cvphp.ismobile( $("#regForm .user").val() )){
	    				cvphp.msg({
	    					content: '手机号码不符合规范'
	    				});
	    				return false;
	    			}
	    			$(".verify input").val('');
	    			var imgUrl = "{:U('Index/verify',array('t','randTime'))}";
	    			imgUrl = imgUrl.replace(/randTime/,Date.parse(new Date()));
	    			$(".verify img").attr('src',imgUrl);
	    			$(".verify").show();
	    			$(".zhezhao").show();
	    			$(".verify input").focus();
	    		});
	    		$("#verifyClose").on('clregBtnick',function(){
	    			$(".verify").hide();
	    			$(".zhezhao").hide();
	    		});
	    		$(".yz img").on('click',function(){
	    		    getImg();
	    		});
	    		$(".verify img").on('click',function(){
	    			var imgUrl = "{:U('Index/verify',array('t','randTime'))}";
	    			imgUrl = imgUrl.replace(/randTime/,Date.parse(new Date()));
	    			$(".verify img").attr('src',imgUrl);
	    		});
	    		$("#verifySendcode").on('click',function(){
	    			$(".verify").hide();
	    			$(".zhezhao").hide();
	    			var code = $(".verify input").val();
	    			if(code.length != 4){
						cvphp.msg({
	    					content: '请输入正确的图形验证码',
	    				});
	    				return ;
	    			}
	    			cvphp.post(
	    				"{:U('Sms/sendcode')}",
	    				{
	    					verify:code,
	    					user:$("#regForm .user").val(),
	    					type:'reg'
	    				},
	    				function(data){
		    				if(data.status != 1){
		    					cvphp.msg({
		    						content: data.info,
		    					});
		    				}else{
		    					resendTime = 59;
		    					resendFun = setInterval(resend,1000);
				    			$(".verify").hide();
				    			$(".zhezhao").hide();
		    				}
	    				}
	    			);
	    		});
	    		$("#regForm .yzm").on('input',function(){
	    			var code = $(this).val();
	    			if(code.length == 4){
	    				$("#regBtn").removeAttr('disabled');
	    				$("#regBtn").removeClass('abut1');
	    				$("#regBtn").addClass('abut');
	    			}else{
	    				$("#regBtn").attr('disabled',"true");
	    				$("#regBtn").removeClass('abut');
	    				$("#regBtn").addClass('abut1');
	    			}
	    		});
	    		$(".yz input").focus(function(){
                   getImg();
                });
	    		$("#regBtn").on('click',function(){
	    			if(!cvphp.ismobile( $("#regForm .user").val() )){
	    				cvphp.msg({
	    					content: '手机号码不符合规范'
	    				});
	    				return false;
	    			}
	    			if($("#regForm .yzm").val().length != 4){
	    				cvphp.msg({
	    					content: '请输入短信验证码'
	    				});
	    				return false;
	    			}
	    			if($("#regForm .pwd").val().length < 6 || $("#regForm .pwd").val().length > 18){
	    				cvphp.msg({
	    					content: '请输入6-18位登录密码'
	    				});
	    				return false;
	    			}
	    			cvphp.post(
	    				"{:U('Index/ajaxReg')}",
	    				{
	    					username:$("#regForm .user").val(),
	    					code:$("#regForm .yzm").val(),
	    					password:$("#regForm .pwd").val()
	    				},
	    				function(data){
	    				    getImg();
		    				if(data.status != 1){
		    					cvphp.msg({
		    						content: data.info,
		    					});
		    				}else{
		    					cvphp.msg({
		    						content: '注册成功',
		    					});
		    					setTimeout(function(){window.location.href = data.url;},3000);
		    				}
	    				}
	    			);
	    		});
	    	});
	    	function resend(){
	    		if(resendTime == 1){
	    			$(".res_con .yz button").html('重新发送');
	    			clearInterval(resendFun);
	    			$(".res_con .yz button").removeAttr('disabled');
	    		}else{
	    			resendTime--;
	    			$(".res_con .yz button").html(resendTime + ' 秒重试');
	    			$(".res_con .yz button").attr('disabled',"true");
	    		}
	    	}
	    </script>
	</body>
</html>
